package com.qunar.toku.proxy;

import java.lang.reflect.Method;
import java.util.UUID;

public class MethodCaller {
	private String serviceName;
    
    public MethodCaller(String serviceName) {
        this.serviceName = serviceName;
    }
	
	public Future doMethodCall(Object clazz, Method method, Object... args) throws Exception {
		ServiceProxy proxy = ServiceProxy.getProxy(serviceName);
		String key = UUID.randomUUID().toString();
		RequestProtocol protocol = new RequestProtocol(clazz, method.getName(), args, key);
		Future future = proxy.invoke(protocol);

		return future;
	}
}
